package com.chenbei.erp.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chenbei.common.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Schema(description = "采购订单")
@Data
@TableName("erp_purchase_order")
public class PurchaseOrder extends BaseEntity {

    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @TableField("采购单名称")
    @NotBlank(message = "采购单不能为空")
    private String name;

    @TableField("单号")
    private String number;

    @Schema(description = "仓库ID")
    @TableField("warehouse_id")
    @NotNull(message = "仓库不能为空")
    private Long warehouseId;

    @Schema(description = "供应商ID")
    @TableField("supplier_id")
    @NotNull(message = "供应商不能为空")
    private Long supplierId;

    @Schema(description = "采购员ID")
    @TableField("purchase_user_id")
    @NotNull(message = "采购负责人不能为空")
    private Long purchaseUserId;

    @Schema(description = "成本总价")
    @TableField("cost_total_price")
    private BigDecimal costTotalPrice;

    @Schema(description = "采购总优惠价格")
    @TableField("total_discounted_price")
    private BigDecimal TotalDiscountedPrice;

    @Schema(description = "实际支付总金额")
    @TableField("pay_total_price")
    private BigDecimal payTotalPrice;

    @Schema(description = "期望到货日期")
    @TableField("expected_receive_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @NotNull(message = "到货日期不能为空")
    private LocalDate expectedReceiveTime;

    @Schema(description = "状态[0:待审批|1:已审批|2:审批拒绝|3:部分完成|4:已完成]")
    private Integer status;

    @Schema(description = "采购产品清单")
    @TableField(exist = false)
    @NotNull(message = "采购清单不能为空")
    private List<PurchaseOrderDetail> details;

    @Schema(description = "审批人ID")
    @TableField("approver_id ")
    private Long approverId;

    @Schema(description = "审批时间")
    @TableField("approval_time ")
    private LocalDateTime approvalTime;

    @Schema(description = "审批意见")
    @TableField("approval_comment ")
    private String approvalComment;
}
